package com.axsoft.jobimp.types;

import java.util.Calendar;
import java.util.GregorianCalendar;


/**
 * 
 * @author RankoR
 * 
 * DateTime implements UNIX-time. In fact, contains QuadWord.
 */
public class DateTime extends QuadWord {

	private final GregorianCalendar mCalendar;
	
	public DateTime() {
		super();
		mCalendar = new GregorianCalendar();
	}
	
	
	public DateTime(final byte[] pData) {
		super(pData);
		
		mCalendar = new GregorianCalendar();
		setDateTime(mValue);
	}
	
	
	public DateTime(final long pMSecs) {
		super();
		mCalendar = new GregorianCalendar();
		setDateTime(pMSecs);		
	}
	
	
	public GregorianCalendar getCalendar() {
		return mCalendar;
	}
	
	
	public long getTimeInMillis() {
		return mCalendar.getTimeInMillis();
	}
	
	
	public void setDateTime(final long pMSecs) {
		super.setQuadWord(pMSecs);
		
		mCalendar.setTimeInMillis(pMSecs);
	}
	
	public void setDateTime(final Calendar pCalendar) {
		final long msecs = pCalendar.getTimeInMillis();
		setDateTime(msecs);
		
		mCalendar.setTimeInMillis(msecs);
	}
}
